package br.com.verde.exemploteca.concurrency.callable;

import java.util.concurrent.Callable;

public class CalculatePi implements Callable<Double> {
	private int start;
	private int end;

	public CalculatePi(int start, int end) {
		this.start = start;
		this.end = end;
	}

	public Double call() throws Exception {
		double value = 0.0;

		for (int i = start; i <= end; i++) {
			value += Math.pow(-1.0, i + 1) / (2.0 * (double) i - 1.0);
		}

		return value;
	}
}
